from rest_framework.serializers import ModelSerializer
from course import models
#先定义一个序列化器类
class CateSerializer(ModelSerializer):
    class Meta:
        model = models.CategoryModel
        fields = ["id","name"]

class CategorySerializer(ModelSerializer):
    son=CateSerializer(many=True)
    class Meta:
        model = models.CategoryModel
        fields = ["id","name","son"]

class TeacherSerializer(ModelSerializer):
    class Meta:
        model = models.TeacherModel
        fields = ["name","image","jobtitle"]

class CourseSerializer(ModelSerializer):
    teacher= TeacherSerializer()
    class Meta:
        model = models.CourseModel
        fields = "__all__"